<!DOCTYPE html>
<html>
<head>
<title>req_assign</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<link rel="stylesheet" type="text/css"
	href="/codebase/fonts/font_roboto/roboto.css" />
<link rel="stylesheet" type="text/css" href="/codebase/dhtmlx.css" />
<script type="text/javascript" src="/codebase/dhtmlx.js" />
<style>
div#simpleLog {
	height: 200px;
	font-family: Roboto, Arial, Helvetica;
	font-size: 14px;
	color: #404040;
	overflow: auto;
}

div.my_header div.text_block {
	height: 50px;
	line-height: 44px;
	font-size: 28px;
	color: #199BC6;
	margin-left: 5px;
	padding-left: 200px;
	background-image: url("/common/szsrcb-logo.png");
	background-repeat: no-repeat;
	background-position: center left;
}
</style>
<script>
/*<![CDATA[*/
	var myForm,my_form2,my_form3, myGrid,myGrid2,data,myForm2,formStructure;
	var dhxWins ;
	var customCss = {
		video_bitrate : "validate_magenta",
		video_codec : "validate_orange"
	};
	function doOnLoad() {
		//req_query form setup
		if (myForm) {
			myForm.unload();
			myForm = null;
		}
		myForm = new dhtmlXForm("form_req_query");
		//myForm.loadStruct("/common/testmanager/query_staffer.xml");
		myForm.loadStruct("/staffer/query_staffer_form_load");
		myForm.attachEvent("onValidateError", function (name, value, result){
			var tmp_label=myForm.getItemLabel(name);	
		
		    alert("校验【"+tmp_label+"】 值为【"+value+ "】 ， 请更正");
		});
		
		myForm.attachEvent("onButtonClick",function(name){			
			if(name=="search"){													
				var s2=myForm.getSelect("req_analyst");
				 for (var i=0;i<s2.options.length;i++)
				{
					s2.options[i].selected=true
				}	
				myForm.send("/staffer/query_staffer_form_send","post",callback,false);		
			}
			
			if (name =="search_reset") {
				select_all_user(name=="select_all");
				myForm.clear();
			}
			
			if (name == "add2" || name == "remove2") {
					change_user(name=="add2");
				};
				
			if (name == "select_all" || name == "cancel_all") {
				select_all_user(name=="select_all");
			};	
				
				
				
		});		

		//grid setup_
		if (myGrid) {			
			myGrid.clearAll(true);			
		}
		myGrid = new dhtmlXGridObject("grid_req_list");
		//myGrid.loadStruct("/common/testmanager/req_list.xml");
		myGrid.setImagePath("/codebase/imgs/");

		myGrid.setHeader(",Req ID,需求编号,需求标题,测试状态,需求负责人,提出部门,要求完成日,计划完成日");
		myGrid.setInitWidths("50,50,150,300,100,100,150,150,150");
		myGrid.setColAlign("center,center,left,left,left,left,left,left,left");
		myGrid.setColTypes("ra,ro,ro,ro,ro,ro,ro,ro,ro");
		myGrid.setColSorting("str,str,str,str,str,str,str,str,str");
		//myGrid.setColumnIds("first,second");
		myGrid.xml.top = "mytop";
		myGrid.xml.row = "./myrow";
		//myGrid.enableAutoWidth(true);
		//myGrid.enableAutoHeight(true);
		myGrid.init();		
		myGrid.attachEvent("onRowSelect",function(rowID,celInd){
		    //alert("The id of the selected row is "+rowID);		    
		    myGrid.cells(rowID,0).setValue("1");
		    
		});
		
		//grid2
		
		if (myGrid2) {			
			myGrid2.clearAll(true);			
		}
		myGrid2 = new dhtmlXGridObject("grid_test_list");
		//myGrid.loadStruct("/common/testmanager/req_list.xml");
		myGrid2.setImagePath("/codebase/imgs/");

		myGrid2.setHeader(",Test ID,需求编号,测试项目,测试状态,测试负责人,要求完成日期,计划完成日,实际完成日,接收日期");
		myGrid2.setInitWidths("50,50,150,300,250,150,150,150,150,150");
		myGrid2.setColAlign("center,center,left,left,left,left,left,left,left,left");
		myGrid2.setColTypes("ra,ro,ed,ro,ro,ro,ro,ro,ro,ro");
		myGrid2.setColSorting("str,int,str,str,str,str,date,date,date,date");
		myGrid2.xml.top = "mytop";
		myGrid2.xml.row = "./myrow";
		//myGrid.enableAutoWidth(true);
		//myGrid.enableAutoHeight(true);
		myGrid2.init();		
		myGrid2.attachEvent("onRowSelect",function(rowID,celInd){
		    //alert("The id of the selected row is "+rowID);		    
		    myGrid2.cells(rowID,0).setValue("1");
		    
		});
		
		//open window button setup
		formStructure=null;
		formStructure=[
		               {type:"button",name:"assign_btn",value:"查看需求项目明细"}
			               ];
		if (my_form2) {
			my_form2.unload();
			my_form2 = null;
		}		
		my_form2=new dhtmlXForm("form_req_query_btn");
		//my_form2.loadStruct(formStructure);
		
		my_form2.attachEvent("onButtonClick", function(name) {		
			var get_row=myGrid.getCheckedRows(0);
			if(get_row==""){
				alert("请先选择一条需求");
			}else{
				createWindow();	
			}
		});
		
		//open window button setup
		formStructure=null;
		formStructure=[
		               {type:"button",name:"test_detail_btn",value:"查看测试项目明细"}
			               ];
		if (my_form3) {
			my_form3.unload();
			my_form3 = null;
		}		
		my_form3=new dhtmlXForm("form_test_btn");
		//my_form3.loadStruct(formStructure);
		
		my_form3.attachEvent("onButtonClick", function(name) {		
			var get_row=myGrid2.getCheckedRows(0);
			if(get_row==""){
				alert("请先选择一条需求");
			}else{
				createWindow2();	
			}
		});
			

	}
	function callback(){
		if (arguments[1]=="false"){
			alert("查询信息失败！callback : "+arguments[1]);
			//window.location.pathname="index";
		}else{
			var r=arguments[1].split(";");
			var r_array=r[0].split(",");
			//String r="req_size="+req_count+",plan_workload="+plan_workload_sum+",actual_workload="+actual_workload_sum+",req_ids="+req_ids;
			myForm.setItemLabel("test_count",r_array[0]);
			myForm.setItemLabel("test_case_count",r_array[1]);			
			myForm.setItemLabel("deffect_count",r_array[2]);
			myForm.setItemLabel("test_plan_workload_count",r_array[3]);			
			myForm.setItemLabel("test_act_workload_count",r_array[4]);
			var ids=r_array[5];
			myGrid2.clearAndLoad("/test/query_test_grid?" + ids,"json");
			
			var r_array2=r[1].split(",");
			
			//String r="req_size="+req_count+",plan_workload="+plan_workload_sum+",actual_workload="+actual_workload_sum+",req_ids="+req_ids;
			myForm.setItemLabel("req_count",r_array2[0]);
			myForm.setItemLabel("req_plan_workload_count",r_array2[1]);
			myForm.setItemLabel("req_act_workload_count",r_array2[2]);
			var ids2=r_array2[3];
			myGrid.clearAndLoad("/req/query_req_grid?" + ids2,"json");	
			
			alert("查询信息成功");
			
		}
	}	
	
	function change_user(block) {
		
		var ida = (block?"req_analyst":"req_analyst_all");
		var idb = (block?"req_analyst_all":"req_analyst");
		
		var sa = myForm.getSelect(ida);
		var sb = myForm.getSelect(idb);
		
		var t = myForm.getItemValue(ida);
		if (t.length == 0) return;
		eval("var k={"+t.join(":true,")+":true};");
		
		var w = 0;
		var ind = -1;
		while (w < sa.options.length) {
			if (k[sa.options[w].value]) {
				sb.options.add(new Option(sa.options[w].text,sa.options[w].value));
				sa.options.remove(w);
				ind = w;
			} else {
				w++;
			}
		}
		
		if (sa.options.length > 0 && ind >= 0) {
			if (sa.options.length > 0) sa.options[t.length>1?0:Math.min(ind,sa.options.length-1)].selected = true;
		}
		
	}
	
function select_all_user(block) {
		
	var idb = (block?"req_analyst":"req_analyst_all");
	var ida = (block?"req_analyst_all":"req_analyst");
		
		
		var sa = myForm.getSelect(ida);
		var sb = myForm.getSelect(idb);
		
	/*	var t = myForm.getItemValue(ida);
		if (t.length == 0) return;
		eval("var k={"+t.join(":true,")+":true};");
		*/
		
		var w = 0;
		var ind = -1;
		while (w < sa.options.length) {
			//if (k[sa.options[w].value]) {
				sb.options.add(new Option(sa.options[w].text,sa.options[w].value));
				sa.options.remove(w);
//				ind = w;
	//		} else {
		//		w++;
			//}
		}
		
	/*	if (sa.options.length > 0 && ind >= 0) {
			if (sa.options.length > 0) sa.options[t.length>1?0:Math.min(ind,sa.options.length-1)].selected = true;
		}
		*/
	}
	
	function createWindow() {
		//alert("open_createWindow");
		
		var id = "req_window";
		//
		var w = 1000;
			var h = 500;
			var x = 10;
			var y = 10;
		//
		var dhxWins=new dhtmlXWindows();
		dhxWins.createWindow(id, x, y, w, h);
		dhxWins.window(id).setText("需求项目信息");
		
		dhxWins.window(id).denyPark();
		dhxWins.window(id).button("park").hide();
		
		dhxWins.window(id).setModal(true);
		
		var get_row=myGrid.getCheckedRows(0);
		var get_req_id=myGrid.cells(get_row,1).getValue();	
		dhxWins.window(id).attachURL("/req/req_modify_detail?req_id="+get_req_id);
	}
	
	function createWindow2() {
		//alert("open_createWindow");
		
		var id = "test_window";
		//
		var w = 1000;
			var h = 500;
			var x = 10;
			var y = 10;
		//
		var dhxWins=new dhtmlXWindows();
		dhxWins.createWindow(id, x, y, w, h);
		dhxWins.window(id).setText("测试信息");
		
		dhxWins.window(id).denyPark();
		dhxWins.window(id).button("park").hide();
		
		dhxWins.window(id).setModal(true);
		
		var get_row=myGrid2.getCheckedRows(0);
		var get_req_id=myGrid2.cells(get_row,1).getValue();	
		dhxWins.window(id).attachURL("/test/test_modify_detail?test_id="+get_req_id);

	
	}
	/*]]>*/		
</script>
</head>
<body onload="doOnLoad();">
	<table>
		<tr>
			<td>
				<div id="form_req_query" style="padding-left: 100px;"></div>
			</td>
		</tr>
		<tr>
			<td><br></br>
				<a>需求项目列表</a>
			</td>
		</tr>
	
		<tr>
			<td>
			<div id="form_req_list" style="padding-left: 100px;"></div>
				<div id="grid_req_list"
					style="width: 1000px; height: 200px; background-color: white;">
					</div>
			</td>
		</tr>
		<tr>
			<td>
				<div id="form_req_query_btn" style="padding-left: 100px;"></div>
			</td>
		</tr>
		<tr>
			<td><br></br>
				<a>测试项目列表</a>
			</td>
		</tr>
		<tr>
			<td>			
				<div id="grid_test_list"
					style="width: 1000px; height: 200px; background-color: white;">
					</div>
			</td>
		</tr>
		
		<tr>
			<td>
				<div id="form_test_btn" style="padding-left: 100px;"></div>
			</td>
		</tr>		
		
	</table>
</body>
</html>